package com.g4.shoppingsingle.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.g4.shoppingsingle.mapper.DdProductInfoMapper;
import com.g4.shoppingsingle.model.DdProductInfo;
import com.g4.shoppingsingle.service.IDdProductInfoService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 商品表 服务实现类
 * </p>
 *
 * @author admin
 * @since 2021-10-27
 */
@Service
public class DdProductInfoServiceImpl extends ServiceImpl<DdProductInfoMapper, DdProductInfo> implements IDdProductInfoService {

    @Autowired(required = false)
    DdProductInfoMapper ddProductInfoMapper;

    @Override
    public PageInfo<DdProductInfo> pdName(Integer pdType, Integer pageNum,Integer pageSize) {

        //只要在执行查询前设置PageHelper分页,这次查询就会自动变为分页查询
        //startPage([页码(1表示第一页)],[每页条数])
        PageHelper.startPage(pageNum,pageSize);
        //select * from dd_product_info limit 1,10;
        QueryWrapper<DdProductInfo> wrapper = new QueryWrapper<>();
//        //select * from dd_product_info where pd_name="小米6" limit 1,10;
        wrapper.eq("pd_type",pdType);

        List<DdProductInfo> list = ddProductInfoMapper.selectList(wrapper);
        return new PageInfo<DdProductInfo>(list);
    }
}
